<?php
	include_once("Login.php");
	
	$conn = new mysqli($host,$user,$passwd, $database)
	or die("SQL connect error: ".mysqli_connect_error());
	
	$id = $_REQUEST["id"];
	$mode = $_REQUEST["mode"];
	
	if($mode == 'touserid'){
		$query = "SELECT * FROM Message WHERE ToUserId = " . $id;	
	}elseif($mode == 'messageid'){
		$query = "SELECT * FROM Message WHERE Id = " . $id;
	}elseif($mode == 'fromuserid'){
		$query = "SELECT * FROM Message WHERE FromUserId = " . $id;
	}
	
	
	
	
	
	
	$result = mysqli_query($conn, $query);
	while($row = mysqli_fetch_array($result))
	{
		?>
		<message>
			<id>
				<?= $row['Id'] ?>
			</id>
			<from>
				<?= $row['FromUserId'] ?>
			</from>
			<content>
				<?= $row['Message'] ?>
			</content>
		</message>

		<?php
	}
	mysqli_close($conn);
?>